<?php
class tx_products_TCEhook
{
	function processCmdmap_preProcess($command, $table, $id, $fields, &$tce)
	{
		if ($table == 'tx_commerce_products' && $command == 'delete')
		{
			$priceAndRestRecords = t3lib_BEfunc::getRecordsByField(
				'user_farm_commerce_product_branch_mm',
				'product_id',
				$id
			);
			
			if (is_array($priceAndRestRecords))
			{
				$cmd = array('user_farm_commerce_product_branch_mm' => array());
				
				foreach($priceAndRestRecords as $priceAndRestRecord)
				{
					$cmd['user_farm_commerce_product_branch_mm'][$priceAndRestRecord['uid']] = array(
						"delete" => 1
					);
				}
				
				$localTCE = t3lib_div::makeInstance('t3lib_TCEmain');

				$localTCE->stripslashes_values = 0;
				$localTCE->start(array(), $cmd);
				$localTCE->process_cmdmap ();
			}
		}
	}
	
}
?>